package net.models;

// Generated 27 mars 2014 20:49:56 by Hibernate Tools 3.4.0.CR1

import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;

import static javax.persistence.GenerationType.IDENTITY;

import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 * Product generated by hbm2java
 */
@Entity
@Table(name = "product", catalog = "scrumtool")
public class Product implements java.io.Serializable {

	private Integer id;
	private String name;
	private String description;
	private Set<Sprint> sprints = new HashSet<Sprint>(0);
	private Set<Playrole> playroles = new HashSet<Playrole>(0);
	private Set<Userstory> userstories = new HashSet<Userstory>(0);

	public Product() {
	}

	public Product(String name, String description, Set<Sprint> sprints,
			Set<Playrole> playroles, Set<Userstory> userstories) {
		this.name = name;
		this.description = description;
		this.sprints = sprints;
		this.playroles = playroles;
		this.userstories = userstories;
	}

	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "id", unique = true, nullable = false)
	public Integer getId() {
		return this.id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	@Column(name = "name", length = 45)
	public String getName() {
		return this.name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@Column(name = "description", length = 65535)
	public String getDescription() {
		return this.description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	@OneToMany(fetch = FetchType.LAZY, mappedBy = "product",cascade =CascadeType.ALL)
	public Set<Sprint> getSprints() {
		return this.sprints;
	}

	public void setSprints(Set<Sprint> sprints) {
		this.sprints = sprints;
	}

	@OneToMany(fetch = FetchType.LAZY, mappedBy = "product",cascade =CascadeType.ALL)
	public Set<Playrole> getPlayroles() {
		return this.playroles;
	}

	public void setPlayroles(Set<Playrole> playroles) {
		this.playroles = playroles;
	}

	@OneToMany(fetch = FetchType.LAZY, mappedBy = "product",cascade =CascadeType.ALL)
	public Set<Userstory> getUserstories() {
		return this.userstories;
	}

	public void setUserstories(Set<Userstory> userstories) {
		this.userstories = userstories;
	}

	@Override
	public String toString() {
		return name;
	}
	
	@Override
	public boolean equals(Object obj) {
		if(obj==null)
			return false;
		if(obj.getClass().equals(this.getClass())){
			Product product=(Product) obj;
			return id.equals(product.getId());
		}
		return false;
	}
}
